*** Settings ***
Documentation    用户登录
Library     SeleniumLibrary

*** Variables ***
${main_url}     http://39.107.96.138:3000/

*** Keywords ***
打开谷歌浏览器到网址
    Open Browser      ${main_url}      Chrome       remote_url=http://47.100.175.62:4444/wd/hub
    Maximize Browser Window

设置等待时间
    Set Selenium Implicit Wait    10
    Set Selenium Speed    0.3

关闭浏览器
    Close Window

刷新页面
    Reload Page

删除浏览器Cookie
    Delete All Cookies

点击登录按钮
    Click Element   //a[@href="/signin"]

输入用户名密码点击登录
    [Arguments]   ${username}    ${password}
    Input Text    //*[@id="name"]     ${username}
    Input Text    //*[@id="pass"]    ${password}
    Click Element    //input[@type="submit"]

验证登录成功
    [Arguments]   ${username}
    Element Text Should Be    //span[@class="user_name"]/a[@class="dark"]    ${username}

验证登录失败
    [Arguments]   ${error_message}
    Element Text Should Be  //strong     ${error_message}
